package com.abvnet.project.water.project.controller;

import com.abvnet.framework.aspectj.lang.annotation.Log;
import com.abvnet.framework.aspectj.lang.enums.BusinessType;
import com.abvnet.framework.web.controller.BaseController;
import com.abvnet.framework.web.domain.AjaxResult;
import com.abvnet.framework.web.page.TableDataInfo;
import com.abvnet.project.water.project.domain.ProjectCustomerLog;
import com.abvnet.project.water.project.service.IProjectCustomerLogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 客户日志信息操作处理
 * 
 * @author duj
 * @date 2019-08-17
 */
@Controller
@RequestMapping("/project/projectCustomerLog")
public class ProjectCustomerLogController extends BaseController {
    private String prefix = "project/projectCustomerLog";
	
	@Autowired
	private IProjectCustomerLogService projectCustomerLogService;
	
	@RequiresPermissions("project:projectCustomerLog:view")
	@GetMapping()
	public String projectCustomerLog()
	{
	    return prefix + "/list";
	}
	
	/**
	 * 查询客户日志列表
	 */
	@RequiresPermissions("project:projectCustomerLog:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(ProjectCustomerLog projectCustomerLog) {
		startPage();
        List<ProjectCustomerLog> list = projectCustomerLogService.selectProjectCustomerLogList(projectCustomerLog);
		return getDataTable(list);
	}

    @RequiresPermissions("project:projectCustomerLog:list")
    @GetMapping("/detail/{customerLogId}")
    public String detail(@PathVariable("customerLogId") Long customerLogId, ModelMap mmap) {
        mmap.put("projectCustomerLog", projectCustomerLogService.selectProjectCustomerLogById(customerLogId));
        return prefix + "/detail";
    }
	
	/**
	 * 新增客户日志
	 */
	@GetMapping("/add")
	public String add() {
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存客户日志
	 */
	@RequiresPermissions("project:projectCustomerLog:add")
	@Log(title = "客户日志", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(ProjectCustomerLog projectCustomerLog) {
		return toAjax(projectCustomerLogService.insertProjectCustomerLog(projectCustomerLog));
	}

	/**
	 * 修改客户日志
	 */
	@GetMapping("/edit/{customerLogId}")
	public String edit(@PathVariable("customerLogId") Long customerLogId, ModelMap mmap) {
		ProjectCustomerLog projectCustomerLog = projectCustomerLogService.selectProjectCustomerLogById(customerLogId);
		mmap.put("projectCustomerLog", projectCustomerLog);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存客户日志
	 */
	@RequiresPermissions("project:projectCustomerLog:edit")
	@Log(title = "客户日志", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(ProjectCustomerLog projectCustomerLog) {
		return toAjax(projectCustomerLogService.updateProjectCustomerLog(projectCustomerLog));
	}
	
	/**
	 * 删除客户日志
	 */
	@RequiresPermissions("project:projectCustomerLog:remove")
	@Log(title = "客户日志", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids) {
		return toAjax(projectCustomerLogService.deleteProjectCustomerLogByIds(ids));
	}
	
}
